import service from '/@/utils/request';

export const useLadderRuleCreateApi = (formData: object) => {
    return service({
        url: `v0/ladder/rule/create`,
        method: 'POST',
        data: formData
    });
}

export const useLadderRuleDeleteApi = (param: string | string[]) => {
    let arrList: string[] = []

    if (param instanceof Array) {
        arrList = param
    } else {
        arrList.push(param)
    }

    return service({
        url: `v0/ladder/rule/delete`,
        method: 'DELETE',
        data: { codeList: arrList }
    });
}

export const useLadderRuleUpdateApi = (formData: object) => {
    return service({
        url: `v0/ladder/rule/update`,
        method: 'PUT',
        data: formData
    });
}

export const useLadderRuleQueryApi = (code: string,) => {
    return service({
        url: `v0/ladder/rule/query`,
        method: 'GET',
        params: { code: code },
    });
}

export const useLadderRulePageApi = (formData?: object) => {
    return service({
        url: `v0/ladder/rule/page`,
        method: 'POST',
        data: formData
    });
}

/**关联角色*/
export const useLadderRuleAddRoleApi = (formData?: object) => {
    return service({
        url: `v0/ladder/rule/addRole`,
        method: 'POST',
        data: formData
    });
}
export const useLadderRuleRemoveRoleApi = (formData?: object) => {
    return service({
        url: `v0/ladder/rule/removeRole`,
        method: 'DELETE',
        data: formData
    });
}
export const useLadderRuleRolePageApi = (formData?: object) => {
    return service({
        url: `v0/ladder/rule/rolePage`,
        method: 'POST',
        data: formData
    });
}
/**关联点位*/
export const useLadderRuleAddUnitApi = (formData?: object) => {
    return service({
        url: `v0/ladder/rule/addUnit`,
        method: 'POST',
        data: formData
    });
}
export const useLadderRuleRemoveUnitApi = (formData?: object) => {
    return service({
        url: `v0/ladder/rule/removeUnit`,
        method: 'DELETE',
        data: formData
    });
}
export const useLadderRuleUnitPageApi = (formData?: object) => {
    return service({
        url: `v0/ladder/rule/unitPage`,
        method: 'POST',
        data: formData
    });
}


/**关联人员 */
export const useLadderRuleAddEmployeeApi = (formData?: object) => {
    return service({
        url: `v0/ladder/rule/addEmployee`,
        method: 'POST',
        data: formData
    });
}
export const useLadderRuleRemoveEmployeeApi = (formData?: object) => {
    return service({
        url: `v0/ladder/rule/removeEmployee`,
        method: 'DELETE',
        data: formData
    });
}
export const useLadderRuleEmployeePageApi = (formData?: object) => {
    return service({
        url: `v0/ladder/rule/employeePage`,
        method: 'POST',
        data: formData
    });
}

/**关联部门 */
export const useLadderRuleAddOrgApi = (formData?: object) => {
    return service({
        url: `v0/ladder/rule/addOrg`,
        method: 'POST',
        data: formData
    });
}
export const useLadderRuleOrgPageApi = (formData?: object) => {
    return service({
        url: `v0/ladder/rule/orgPage`,
        method: 'POST',
        data: formData
    });
}
export const useLadderRuleRemoveOrgApi = (formData?: object) => {
    return service({
        url: `v0/ladder/rule/removeOrg`,
        method: 'DELETE',
        data: formData
    });
}
